﻿using AllinpayEleMe.Widget;
using System.IO;
using System.Runtime.InteropServices;

namespace System
{
    public class RecycleBin : System
    {
        public string GetImagePath()
        {
            const string relativePath = @".\img\system\recycle.png";
            return Path.GetFullPath(relativePath);
        }
        public string GetName()
        {
            return "清理回收站";
        }

        [DllImportAttribute("shell32.dll")]
        private static extern int SHEmptyRecycleBin(IntPtr handle, string root, int flags);

        const int SHERB_NOCONFIRMATION = 0x000001;
        const int SHERB_NOPROGRESSUI = 0x000002;
        const int SHERB_NOSOUND = 0x000004;

        public void DoWork()
        {
            AlertDialog.NewInstance()
                .AddDragMove()
                .SetInfo("请问是否需要清空回收站？")
                .SetPositiveButton("确定", ok)
                .Show();
        }

        private bool ok()
        {
            AyThread.Instance.RunNew(() =>
            {
                SHEmptyRecycleBin(IntPtr.Zero, "", SHERB_NOCONFIRMATION + SHERB_NOPROGRESSUI + SHERB_NOSOUND);
            });
            return true;
        }
    }
}
